/**
 * 评论
 */
var mongoose = require('../dataHelp/mongo');
var schema = mongoose.Schema;

//定义模型
var commentSchema = new schema({
    commentUuid      : String,//评论id
    postId           : String, //帖子id
    uuid             : String, //评论人id
    content          : String, //评论内容 
    name             : String, //评论人姓名
    createTime       : String, //创建时间
    type             : Number, //评论类型 1 评论 2 回复
    replyName        : String, //原评论人
    replyUuid        : String, //原评论人uuid
});

//定义model
var commentModel = mongoose.model('comment',commentSchema);
/**
 * 评论
 * @param {*} params 
 */
commentModel.saveComment = async (params)=>{
    var comment = new commentModel(params);
    return await comment.save()
}
/**
 * 获取该文章的评论
 * @param {*} params 
 */
commentModel.getPostComment = async (params) => {
    return await commentModel.find(params);
}
module.exports = commentModel;